package com.lz.yz.member.web;

import com.github.pagehelper.PageHelper;
import com.lz.yz.base.entity.ReturnValue;
import com.lz.yz.member.entity.Feedback;
import com.lz.yz.member.model.FeedbackModel;
import com.lz.yz.member.service.FeedbackService;
import com.util.common.Page;
import com.util.common.QueryList;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;


@RestController
@RequestMapping("/feedback")
public class FeedbackController {

    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Resource
    private FeedbackService feedbackService;

    @Autowired
    HttpServletRequest request;




    @ApiOperation(value="提交意见反馈")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header",name = "Authorization",value = "Bearer token",defaultValue = "Bearer "),
            @ApiImplicitParam(name = "feedbackModel", value = "订单实体类", dataType = "FeedbackModel", paramType = "body"),
    })
    @PostMapping("/addFeedback")
    public ReturnValue add(@RequestBody FeedbackModel feedbackModel) {
        try {
            Integer accountId = (Integer) request.getAttribute("accountId");
            return feedbackService.add(accountId,feedbackModel);
        } catch (Exception e) {
            logger.error("提交意见反馈出错" + feedbackModel, e);
            return ReturnValue.generateFalseReturnValue("提交失败");
        }
    }

}
